#include "get_output_filename.h"

#define BASE_NAME "time_temp"
#define EXTENSION "csv"

std::string get_output_filename(){
	// 获取当前时间
    auto now=std::chrono::system_clock::now();
	// 转换为time_t类型c-style time
    time_t now_c=std::chrono::system_clock::to_time_t(now);

    /* local time */
    tm now_tm;
#ifdef _WIN32
    /* windows */
    /* localtime_s in windows */
    localtime_s(&now_tm, &now_c);
#else
    /* linux_ubuntu */
    localtime_r(&now_c, &now_tm);
#endif

	// 创建一个字符串流以构建文件名
    std::ostringstream file_name_stream;
	file_name_stream
		<<BASE_NAME<<"_"
        <<std::put_time(&now_tm, "%Y%m%d_%H%M")
		<<"."<<EXTENSION;
	
	return file_name_stream.str();
}
